package com.ruoyi.activity.controller.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.activity.req.EvaluateListReq;
import com.ruoyi.activity.req.WorksListReq;
import com.ruoyi.activity.resp.EvaluateResp;
import com.ruoyi.common.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.activity.domain.Evaluate;
import com.ruoyi.activity.service.IEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价管理Controller
 *
 * @author wxc
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/admin/evaluate")
public class EvaluateController extends BaseController
{
    @Autowired
    private IEvaluateService evaluateService;

    /**
     * 查询评价管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EvaluateListReq evaluate)
    {
        startPage();
        List<EvaluateResp> list = evaluateService.selectEvaluateList(evaluate);
        return getDataTable(list);
    }

    /**
     * 导出评价管理列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, Evaluate evaluate)
    {
        EvaluateListReq evaluateListReq = new EvaluateListReq();
        //复制works属性到worksListReq
        BeanUtils.copyProperties(evaluate, evaluateListReq);
        List<EvaluateResp> list = evaluateService.selectEvaluateList(evaluateListReq);
        ExcelUtil<EvaluateResp> util = new ExcelUtil<EvaluateResp>(EvaluateResp.class);
        util.exportExcel(response, list, "评价管理数据");
    }

    /**
     * 获取评价管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(evaluateService.selectEvaluateById(id));
    }

  }
